﻿<Page
    x:Class="EncryptionExample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:EncryptionExample"
    xmlns:data="using:EncryptionExample.Data"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Resources>
        <x:String x:Key="AppName">Encryption Example</x:String>
    </Page.Resources>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="140"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" Margin="0,0,30,40" VerticalAlignment="Bottom"/>
        </Grid>

        <Grid Grid.Row="1" Margin="120 0 0 0">
            <Grid.DataContext>
                <data:ViewModel>
                    <data:ViewModel.Dialog>
                        <data:DialogService/>
                    </data:ViewModel.Dialog>
                </data:ViewModel>
            </Grid.DataContext>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="5*"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="5*"/>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Filters: " Style="{StaticResource BaseTextBlockStyle}" FontWeight="Bold"/>
                <CheckBox IsChecked="{Binding Asymmetric, Mode=TwoWay}" Margin="10 0 0 0"/>
                <TextBlock Text="Asymmetric Only" Style="{StaticResource BaseTextBlockStyle}"/>
                <CheckBox IsChecked="{Binding Symmetric, Mode=TwoWay}" Margin="10 0 0 0"/>
                <TextBlock Text="Symmetric Only" Style="{StaticResource BaseTextBlockStyle}"/>
                <CheckBox IsChecked="{Binding Block, Mode=TwoWay}" Margin="10 0 0 0"/>
                <TextBlock Text="Block" Style="{StaticResource BaseTextBlockStyle}"/>
                <CheckBox IsChecked="{Binding Stream, Mode=TwoWay}" Margin="10 0 0 0"/>
                <TextBlock Text="Stream" Style="{StaticResource BaseTextBlockStyle}"/>
                <CheckBox IsChecked="{Binding Authenticated, Mode=TwoWay}" Margin="10 0 0 0"/>
                <TextBlock Text="Authenticated" Style="{StaticResource BaseTextBlockStyle}"/>
                <CheckBox IsChecked="{Binding Pkcs7, Mode=TwoWay}" Margin="10 0 0 0"/>
                <TextBlock Text="PKCS#7" Style="{StaticResource BaseTextBlockStyle}"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Row="1">
                <CheckBox IsChecked="{Binding Verification, Mode=TwoWay}" Margin="56 0 0 0"/>
                <TextBlock Text="Verification" Style="{StaticResource BaseTextBlockStyle}"/>
                <CheckBox IsChecked="{Binding Hash, Mode=TwoWay}" Margin="10 0 0 0"/>
                <TextBlock Text="Hash" Style="{StaticResource BaseTextBlockStyle}"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Grid.Row="2">
                <TextBlock Text="Select the Algorithm:" Style="{StaticResource BaseTextBlockStyle}" FontWeight="Bold"/>
                <ComboBox ItemsSource="{Binding Algorithms}" SelectedItem="{Binding SelectedAlgorithm, Mode=TwoWay}" DisplayMemberPath="Name"/>
            </StackPanel>
            <TextBlock Text="Text to Encrypt or Decrypted Text:" Style="{StaticResource BaseTextBlockStyle}" FontWeight="Bold" Grid.Row="3"/>
            <TextBox Text="{Binding EncryptionInput, Mode=TwoWay}" TextWrapping="Wrap" Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10 30 10 10"/>
            <StackPanel Grid.Row="4" Orientation="Horizontal">
                <StackPanel Orientation="Vertical" Visibility="{Binding RequiresPassword, Converter={StaticResource BoolVisConverter}}">
                    <TextBlock Text="Password:" Style="{StaticResource BaseTextBlockStyle}" FontWeight="Bold" Grid.Row="2"/>
                    <PasswordBox Width="200" Password="{Binding KeyInput, Mode=TwoWay}" HorizontalAlignment="Left" Margin="0 10 0 0"/>
                </StackPanel>
                <Button Content="Encrypt" IsEnabled="{Binding SelectedAlgorithm.IsEncryptionAlgorithm}" Command="{Binding}" VerticalAlignment="Top" Margin="10 0 0 0" CommandParameter="encrypt"/>
                <Button Content="Decrypt" IsEnabled="{Binding SelectedAlgorithm.IsEncryptionAlgorithm}" Command="{Binding}" VerticalAlignment="Top" Margin="10 0 0 0" CommandParameter="decrypt"/>
                <Button Content="Sign" IsEnabled="{Binding SelectedAlgorithm.IsVerificationAlgorithm}" Command="{Binding}" VerticalAlignment="Top" Margin="10 0 0 0" CommandParameter="sign"/>
                <Button Content="Verify" IsEnabled="{Binding SelectedAlgorithm.IsVerificationAlgorithm}" Command="{Binding}" VerticalAlignment="Top" Margin="10 0 0 0" CommandParameter="verify"/>
            </StackPanel>
            <TextBlock Text="Text to Decrypt or Encrypted Text:" Style="{StaticResource BaseTextBlockStyle}" FontWeight="Bold" Grid.Row="5"/>
            <TextBox Text="{Binding DecryptionInput, Mode=TwoWay}" TextWrapping="Wrap" Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10 30 10 10"/>
        </Grid>


    </Grid>
</Page>
